<template>
	<view class="record-his">
		<view class="record-list" v-if="list && list.length > 0 && !showMore">
			<view class="record-list-item" :style="{ alignItems: !isCorrection ? 'flex-start' : 'center' }"
				v-for="(item, index) in [list[0]]" :key="item.id">
				<view class="user-head">{{ (userName || '').slice(-2) }}</view>
				<view class="info">
					<view class="info-content">
						<text style="margin-right: 15rpx;">{{ userName }}</text>
						<text v-if="!isCorrection">{{ item.recordLog || '修改了信息' }}</text>
						<text v-else>{{ item.updateTime }}</text>
					</view>
					<view class="info-time" v-if="!isCorrection">{{ item.updateTime }}</view>
				</view>
			</view>
		</view>
		<view class="record-list" v-if="list && list.length > 0 && showMore">
			<view class="record-list-item" v-for="(item, index) in list" :key="item.id">
				<view class="user-head" :style="{ backgroundColor: index == 0 ? '#0091ff' : '#fff' }">{{ (userName ||
					'').slice(-2) }}</view>
				<view class="info">
					<view class="info-content">
						<text style="margin-right: 15rpx;">{{ userName }}</text>
						<text v-if="!isCorrection">{{ item.recordLog || '修改了信息' }}</text>
						<text v-else>{{ item.updateTime }}</text>
					</view>
					<view class="info-time" v-if="!isCorrection">{{ item.updateTime }}</view>
				</view>
			</view>
		</view>
		<view class="record-more" v-if="list && list.length > 1 && !showMore" @click="showMoreRecord">
			<view>展开记录</view>
			<view>
				<image src="@/static/images/index/left.png" style="transform: rotate(270deg);"></image>
			</view>
		</view>
		<view class="record-more" v-if="list && list.length > 1 && showMore" @click="showMoreRecord">
			<view>收起记录</view>
			<view>
				<image src="@/static/images/index/left.png" style="transform: rotate(90deg);"></image>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'record-his',
	props: {
		userId: [String, Number],
		userName: String,
		list: Array,
		isCorrection: {  // 是否未整改
			type: Boolean,
			default: false
		},
	},
	data() {
		return { showMore: false };
	},
	methods: {
		showMoreRecord() {
			console.log(this.list, "checkRecords的值")
			this.showMore = !this.showMore;
			this.$forceUpdate();
		}
	}
};
</script>

<style lang="scss" scoped>
.record-list {
	width: 100%;
	margin-top: 20rpx;

	&-item {
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		font-size: 24rpx;
		line-height: 33rpx;
		margin-bottom: 10rpx;

		image {
			width: 25rpx;
			height: 25rpx;
			padding-top: 5rpx;
		}

		.info {
			width: calc(100% - 35rpx);
			color: #999;

			text {
				color: #333;

			}
		}
	}
}

.record-more {
	width: fit-content;
	height: 34rpx;
	font-size: 24rpx;
	font-family: PingFangSC, PingFangSC-Regular;
	font-weight: 400;
	text-align: left;
	color: #0091ff;
	line-height: 34rpx;
	display: flex;
	align-items: center;
	position: relative;

	image {
		position: absolute;
		top: 0;
		bottom: 0;
		margin: auto;
		width: 24rpx;
		height: 24rpx;
	}
}

.user-head {
	width: 46rpx;
	height: 46rpx;
	color: #fff;
	background-color: #0091ff;
	border-radius: 50%;
	text-align: center;
	font-size: 18rpx;
	line-height: 42rpx;
	margin-right: 12rpx;
	overflow: hidden;
}
</style>
